import requests from "@/utils/request";

// 获取产品列表
export function getGoodList(query) {
    return requests({
        url: '/system/admin/good/getGoodTableList',
        method: 'get',
        params: query
    })
}

// 获取产品信息
export function getGood(goodId) {
    return requests({
        url: '/system/admin/good/getGood/' + goodId,
        method: 'get'
    })
}

// 添加产品
export function insertGood(form) {
    let good_img = form.good_img
    let good_title = form.good_title
    let price = form.price
    let seckill_price = form.seckill_price
    let total = form.total
    let good_desc = form.good_desc
    let start_time = form.start_time
    let end_time = form.end_time
    return requests({
        url: '/system/admin/good/addGood',
        method: 'post',
        data: {
            good_img,
            good_title,
            price,
            seckill_price,
            total,
            good_desc,
            start_time,
            end_time
        }
    })
}

// 修改产品
export function modifyGood(form) {
    let good_id = form.good_id
    let good_img = form.good_img
    let good_title = form.good_title
    let price = form.price
    let seckill_price = form.seckill_price
    let total = form.total
    let good_desc = form.good_desc
    let start_time = form.start_time
    let end_time = form.end_time
    return requests({
        url: '/system/admin/good/modifyGood',
        method: 'put',
        data: {
            good_id,
            good_img,
            good_title,
            price,
            seckill_price,
            total,
            good_desc,
            start_time,
            end_time
        }
    })
}

// 删除产品
export function deleteGood(goodId) {
    return requests({
        url: '/system/admin/good/deleteGood/' + goodId,
        method: 'delete'
    })
}
